<template>
  <div class="app-container" style="padding-top:0px">
    <!-- 安规测试结果 -->
    <div class="contentDiv">
      <!-- <h1 style="margin-left:40%">产品测试报告</h1> -->
      <el-form
        ref="form"
        class="perForm"
        :model="caseInfo"
        label-width="120px"
        size="medium"
        :inline="true"
        style="margin-top: 30px"
      >
        <el-form-item label="整机条码" prop="caseId">
          <el-input v-model="caseInfo.caseId" />
        </el-form-item>
        <el-form-item label="产线号" prop="lineId">
          <el-input v-model="caseInfo.lineId" />
        </el-form-item>
        <el-form-item label="老化房号" prop="burninId">
          <el-input v-model="caseInfo.burninId" />
        </el-form-item>
        <el-form-item label="调试台号" prop="testId">
          <el-input v-model="caseInfo.testId" />
        </el-form-item>
        <el-form-item label="产品型号" prop="productStandard">
          <el-input v-model="caseInfo.productStandard" />
        </el-form-item>
        <el-form-item label="生产批号" prop="taskId">
          <el-input v-model="caseInfo.taskId" />
        </el-form-item>
        <el-form-item label="质检员" prop="inspectName">
          <el-input v-model="caseInfo.inspectName" />
        </el-form-item>
        <el-form-item label="老化人员" prop="agingName">
          <el-input v-model="caseInfo.agingName" />
        </el-form-item>
        <el-form-item label="调试人员" prop="debugName">
          <el-input v-model="caseInfo.debugName" />
        </el-form-item>
        <el-form-item label="客户名称" prop="customer">
          <el-input v-model="caseInfo.customer" />
        </el-form-item>
        <el-form-item label="产品类型" prop="productType">
          <el-input v-model="caseInfo.productType" />
        </el-form-item>
        <el-form-item label="质检结果" prop="inspectResult">
          <el-input v-model="caseInfo.inspectResult" />
        </el-form-item>
        <el-form-item label="老化结果" prop="ageingResult">
          <el-input v-model="caseInfo.ageingResult" />
        </el-form-item>
        <el-form-item label="调试结果" prop="debugResult">
          <el-input v-model="caseInfo.debugResult" />
        </el-form-item>
      </el-form>

      <el-tag size="large" style="font-size: 20px;">组装质检信息</el-tag>
      <el-table v-loading="loading" :data="modelInstallList" width="80%">
        <el-table-column label="物料编码" align="center" prop="materialId" />
        <el-table-column label="物料名称" align="center" prop="materialName" />
        <el-table-column label="物料规格" align="center" prop="materialStandard" />
        <el-table-column label="批次流水号" align="center" prop="materialBatch" />
        <el-table-column label="安装时间" align="center" prop="installTime" />
        <el-table-column label="装配员" align="center" prop="installName" />
        <!-- <el-table-column label="检测日期" align="center" prop="inspectDatealarmtestedTime" width="180">
                    <template slot-scope="scope">
                    <span>{{ parseTime(scope.row.inspectDate, '{y}-{m}-{d}') }}</span>
                    </template>
        </el-table-column>-->
      </el-table>

      <el-tag size="large" style="font-size: 20px;">安规测试结果</el-tag>
      <el-form
        ref="pressureTest"
        class="perForm"
        :model="pressureTest"
        label-width="120px"
        size="medium"
        :inline="true"
        style="margin-top: 15px"
      >
        <el-form-item label="耐压值上限(mA)" prop="insulationValueUp">
          <el-input v-model="pressureTest.insulationValueUp" />
        </el-form-item>
        <el-form-item label="耐压值下限(mA)" prop="pressureValueDown">
          <el-input v-model="pressureTest.pressureValueDown" />
        </el-form-item>
        <el-form-item label="耐压值实测(mA)" prop="pressureTestValue">
          <el-input v-model="pressureTest.pressureTestValue" />
        </el-form-item>
        <el-form-item label="绝缘值上限(兆欧)" prop="insulationValueUp">
          <el-input v-model="pressureTest.insulationValueUp" />
        </el-form-item>
        <el-form-item label="绝缘值下限(兆欧)" prop="insulationValueDown">
          <el-input v-model="pressureTest.insulationValueDown" />
        </el-form-item>
        <el-form-item label="绝缘值实测(兆欧)" prop="insulationValue">
          <el-input v-model="pressureTest.insulationValue" />
        </el-form-item>
        <el-form-item label="安规测试结果" prop="passorNot">
          <el-input v-model="pressureTest.passorNot" />
        </el-form-item>
        <el-form-item label="测试时间" prop="testTime">
          <el-input v-model="pressureTest.testTime" />
        </el-form-item>
        <el-form-item label="测试员" prop="testPerson">
          <el-input v-model="pressureTest.testPerson" />
        </el-form-item>
      </el-form>
      <el-tag size="large" style="font-size: 20px;">灌流测试结果</el-tag>
      <el-form
        ref="perfusionResults"
        class="perForm"
        :model="pressureTest"
        label-width="120px"
        size="medium"
        :inline="true"
        style="margin-top: 15px"
      >
        <el-form-item label="气泵Q_U" prop="qu">
          <el-input v-model="pressureTest.qu" />
        </el-form-item>
        <el-form-item label="气泵Q_V" prop="qv">
          <el-input v-model="pressureTest.qv" />
        </el-form-item>
        <el-form-item label="气泵Q_W" prop="qw">
          <el-input v-model="pressureTest.qw" />
        </el-form-item>
        <el-form-item label="油泵Y_U" prop="yu">
          <el-input v-model="pressureTest.yu" />
        </el-form-item>
        <el-form-item label="油泵Y_V" prop="yv">
          <el-input v-model="pressureTest.yv" />
        </el-form-item>
        <el-form-item label="油泵Y_W" prop="yw">
          <el-input v-model="pressureTest.yw" />
        </el-form-item>
        <el-form-item label="DCDC_V" prop="dcdcV">
          <el-input v-model="pressureTest.dcdcV" />
        </el-form-item>
        <el-form-item label="灌流测试结果" prop="guanliuValue">
          <el-input v-model="pressureTest.guanliuValue" />
        </el-form-item>
        <el-form-item label="测试时间" prop="glTime">
          <el-input v-model="pressureTest.glTime" />
        </el-form-item>
        <el-form-item label="测试员" prop="textName">
          <el-input v-model="pressureTest.textName" />
        </el-form-item>
      </el-form>
      <!-- 老化信息 -->
      <el-tag size="large" style="font-size: 20px;">老化信息</el-tag>
      <el-table v-loading="loading" :data="faultInformationList" width="80%">
        <el-table-column label="报警时间" align="center" prop="alarmTime" />
        <el-table-column label="参数名称" align="center" prop="parameterName" />
        <el-table-column label="参数值" align="center" prop="parameterValue" />
        <el-table-column label="故障等级" align="center" prop="faultLevel" />
        <el-table-column label="故障状态" align="center" prop="faultState" />
      </el-table>
      <el-table v-loading="loading" :data="electricalParameterList" width="80%">
        <el-table-column label="时间" align="center" prop="time" />
        <el-table-column label="DCDC电压" align="center" prop="dcdcV" />
        <el-table-column label="DCDC电流" align="center" prop="dcdcA" />
        <el-table-column label="DCAC1电压" align="center" prop="dcac1V" />
        <el-table-column label="DCAC1电流" align="center" prop="dcac1A" />
        <el-table-column label="DCAC2电压" align="center" prop="dcac2V" />
        <el-table-column label="DCAC2电流" align="center" prop="dcac2A" />
        <el-table-column label="电驱电压" align="center" prop="dqV" />
        <el-table-column label="电驱电流" align="center" prop="dqA" />
        <el-table-column label="充电机电流" align="center" prop="cdjA" />
      </el-table>

      <!-- 调试信息 -->
      <el-tag size="large" style="font-size: 20px;">调试信息</el-tag>
      <el-form
        ref="alarm"
        class="alarm"
        :model="alarm"
        label-width="120px"
        size="medium"
        :inline="true"
        style="margin-top: 15px"
      >
        <el-form-item label="控制电压(V)" prop="batteryv">
          <el-input v-model="alarm.batteryv" :disabled="true" />
        </el-form-item>
        <el-form-item label="报警偏差电流" prop="A">
          <el-input v-model="alarm.A" :disabled="true" />
        </el-form-item>
        <el-form-item label="报警偏差电压" prop="V">
          <el-input v-model="alarm.V" :disabled="true" />
        </el-form-item>
      </el-form>

      <el-form
        ref="fault"
        class="fault"
        :model="fault"
        label-width="120px"
        size="medium"
        :inline="true"
        style="margin-top: 15px"
      >
        <el-form-item label="调试日期" prop="testedTime">
          <el-input v-model="form.testedTime" :disabled="true" />
        </el-form-item>
        <el-form-item label="故障偏差电流" prop="A">
          <el-input v-model="fault.A" :disabled="true" />
        </el-form-item>
        <el-form-item label="故障偏差电压" prop="V">
          <el-input v-model="fault.V" :disabled="true" />
        </el-form-item>
      </el-form>

      <el-table v-loading="loading" :data="debugRecordList" width="80%">
        <el-table-column label="采样时间" align="center" prop="timeDateStamp" />
        <el-table-column label="调试模块" align="center" prop="testType" />
        <el-table-column label="调试步骤" align="center" prop="step" />
        <el-table-column label="母线电压" align="center" prop="busV" />
        <el-table-column label="PLC电压(V)" align="center" prop="plcV" />
        <el-table-column label="PLC电流(A)" align="center" prop="plcA" />
        <el-table-column label="CAN电压(V)" align="center" prop="canV" />
        <el-table-column label="CAN电流(A)" align="center" prop="canA" />
        <el-table-column label="电压偏差(%)" align="center" prop="offsetV" />
        <el-table-column label="电流偏差(%)" align="center" prop="offsetA" />
      </el-table>

      <el-table v-loading="loading" :data="testFaultDataList" width="80%">
        <el-table-column label="调试时间" align="center" prop="testTime" />
        <el-table-column label="调试模块" align="center" prop="testType" />
        <el-table-column label="调试步骤" align="center" prop="testStep" />
        <el-table-column label="故障类型" align="center" prop="faultLevel" />
        <el-table-column label="PLC值" align="center" prop="plcValue" />
        <el-table-column label="CAN值" align="center" prop="canValue" />
        <el-table-column label="PLC/CAN偏差" align="center" prop="deviation" />
        <el-table-column label="说明" align="center" prop="demo" />
      </el-table>

      <el-table v-loading="loading" :data="chargerTestList" width="80%">
        <el-table-column label="充电模式" align="center" prop="chargingMode" />
        <el-table-column label="控制电压" align="center" prop="dcV" />
        <el-table-column label="母线电压" align="center" prop="busV" />
        <el-table-column label="电压需求" align="center" prop="minV" />
        <el-table-column label="电流需求" align="center" prop="maxV" />
        <el-table-column label="PLC电压(V)" align="center" prop="plcV" />
        <el-table-column label="PLC电流(A)" align="center" prop="plcA" />
        <el-table-column label="CAN电压(V)" align="center" prop="bmsV" />
        <el-table-column label="CAN电流(A)" align="center" prop="bmsA" />
        <el-table-column label="时间" align="center" prop="time" />
      </el-table>

      <el-tag size="large" style="font-size: 20px;">维修记录</el-tag>
      <el-table v-loading="loading" :data="maintenanceRecords" width="80%">
        <el-table-column label="序号" align="center" width="50px">
          <template slot-scope="scope">
            <span>{{scope.$index + 1}}</span>
          </template>
        </el-table-column>
        <el-table-column label="维修时间" align="center" prop="faultTime" />
        <el-table-column label="维修人" align="center" prop="faultName" />
        <el-table-column label="送修时间" align="center" prop="giveTime" />
        <el-table-column label="送修人" align="center" prop="giveName" />
        <el-table-column label="故障类型" align="center" prop="faultType" />
        <el-table-column label="故障定位" align="center" prop="faultPosition" />
        <el-table-column label="失效分析人" align="center" prop="analysisName" />
        <el-table-column label="装配线" align="center" prop="lineNumber" />
      </el-table>

      
      <el-tag size="large" style="font-size: 20px;">工装机调试数据</el-tag>
      <el-table v-loading="loading" :data="dbData" width="80%">
        <el-table-column label="序号" align="center" width="50px">
          <template slot-scope="scope">
            <span>{{scope.$index + 1}}</span>
          </template>
        </el-table-column>
        <el-table-column label="指标名称" align="center" prop="tagName" />
        <el-table-column label="指标值" align="center" prop="tagValue" />
      </el-table>

    </div>
  </div>
</template>
    
<script>
// reportAll
import { reportAll } from "@/api/mes/pro/workorderSn";
export default {
  name: "productReport",
  data() {
    return {
      //add begin by zyj 2024/10/18 解决第二次点击不能正确显示工装机调试数据的问题
      snCode: null,
      //add end by zyj 2024/10/18 解决第二次点击不能正确显示工装机调试数据的问题
      caseInfo: {},
      modelInstallList: [],
      //安规测试结果
      pressureTest: {},
      //灌流测试结果
      perfusionResults: {},
      form:{},
      //   调试信息
      alarm: {},
      fault: {},
      loading: false,
      // templateList: [],,
      faultInformationList: [],
      electricalParameterList: [],
      //调试信息table1
      debugRecordList: [],
      //调试信息table2
      testFaultDataList: [],
      //调试信息table3
      chargerTestList: [],
      //维修记录
      maintenanceRecords: [],
      //工装机调试数据
      dbData:[],
    };
  },
  //edit begin by zyj 2024/10/18 解决第二次点击不能正确显示工装机调试数据的问题
  // created() {
  //   this.getList();
  // },
  mounted(){
    this.getList();
  },
  //edit end by zyj 2024/10/18 解决第二次点击不能正确显示工装机调试数据的问题
  watch: {
    reportSn: function(val) {
      //edit begin by zyj 2024/10/18 解决第二次点击不能正确显示工装机调试数据的问题
      // this.reportSn = val.snCode;
      // this.getList();

      if(val){
        this.snCode = val.snCode;
        this.getList();
      }
      //edit end by zyj 2024/10/18 解决第二次点击不能正确显示工装机调试数据的问题
      
    }
  },
  props: {
    reportSn: {
      type: Object,
      default: ()=>null
    }
  },
  methods: {
    getList() {
      //EDIT begin by zyj 2024/10/18 解决第二次点击不能正确显示工装机调试数据的问题
      // this.loading = true;
      // reportAll({ caseId: this.reportSn }).then(res => {
      //   console.log(res, "=====res=====");
      //   this.caseInfo = res.data.caseInfo || {};
      //   this.pressureTest = res.data.pressureTest || {};
      //   this.modelInstallList = res.data.modelInstallList || [];
      //   this.faultInformationList = res.data.faultInformationList || [];
      //   this.electricalParameterList = res.data.electricalParameterList || [];
      //   this.alarm = res.data.debug.alarm;
      //   this.fault = res.data.debug.fault;
      //   this.debugRecordList = res.data.debugRecordList;
      //   this.testFaultDataList = res.data.testFaultDataList;
      //   this.chargerTestList = res.data.chargerTestList;
      //   this.maintenanceRecords = res.data.maintenanceRecordList;
      //   this.dbData = res.data.dbData
      //   this.loading = false;
      // });
      if(!this.snCode){
        return
      }
      
      this.loading = true;
      reportAll({ caseId: this.snCode }).then(res => {
        console.log(res, "=====res=====");
        this.caseInfo = res.data.caseInfo || {};
        this.pressureTest = res.data.pressureTest || {};
        this.modelInstallList = res.data.modelInstallList || [];
        this.faultInformationList = res.data.faultInformationList || [];
        this.electricalParameterList = res.data.electricalParameterList || [];
        this.alarm = res.data.debug.alarm;
        this.fault = res.data.debug.fault;
        this.debugRecordList = res.data.debugRecordList;
        this.testFaultDataList = res.data.testFaultDataList;
        this.chargerTestList = res.data.chargerTestList;
        this.maintenanceRecords = res.data.maintenanceRecordList;
        this.dbData = res.data.dbData
        this.loading = false;
      });
      //EDIT end by zyj 2024/10/18 解决第二次点击不能正确显示工装机调试数据的问题
    }
  }
};
</script>
    <style lang="scss" scoped>
// .contentDiv {
//   width: 1350px;
// }
.el-table {
  margin-bottom: 15px;
}
</style>